<style>
  .el-input-group__prepend{
        padding: 0 10px;
    }
</style>
<template>
    <div>
        <el-input class="ly-price" @change="changed" :size="size" :placeholder="placeholder" :disabled="disabled" type="number"
                  v-model.float="price" class="ly-formpayPrice">
            <template slot="prepend">¥</template>
        </el-input>
    </div>
</template>
<script>
    Rap.define(function () {
                return {
                    name: 'ly-price',
                    props: {
                        disabled: Boolean,
                        size: {
                            default: ''
                        },
                        placeholder: {
                            default: '请输入价格'
                        },
                        value: {
                            default: function () {
                                return 0
                            }
                        }
                    },
                    watch: {
                        'value': function (value) {
                            this.price = (value / 100);

                        },
                        'price': function (value) {
                            value = parseInt((parseFloat(value) * 100).toFixed(0));
                            if (value) {
                                this.$emit('input', value);
                            } else {
                                this.$emit('input', 0);
                            }

                        }
                    },
                    created: function () {
                        this.price = (this.value / 100);
                    },
                    data: function () {
                        return {
                            price: ''
                        };
                    },
                    methods: {
                        changed: function () {
                            this.$emit('change', this.value);
                        }
                    }
                }
            }
    )


</script>